package persistence;

import java.util.Collection;
import java.util.Hashtable;
import java.util.List;

import utils.DataDownloader;
import utils.ShowException;

import docks.Dock;

import android.app.Activity;
import android.content.Context;
import android.widget.Toast;

public class DataBaseController {

    private static DataBaseAPI _dbapi;
    private static DataBaseController _instance;
    private static Context ctx;

    public static DataBaseController getInstance() {

	if (_instance == null) {
	    _instance = new DataBaseController();
	}

	return _instance;
    }

    public void initDatabase(Activity a) {

	ctx = a;
	_dbapi = new DataBaseAPIImpl(a);

    }

    public void closeDatabase() {

	// _db.onDestroy();
	_dbapi.onDestroy();
    }

    public long insertFavorite(int id) {

	long r = _dbapi.insertFavorite(id);
	return r;
    }

    public boolean deleteFavorite(int id) {

	long l = _dbapi.deleteFavorite(id);
	return l != 0;
    }

    public List<Dock> getAllStarred() {

	return _dbapi.getFavorites();
    }

    public List<Dock> getAllDocks() {

	return _dbapi.getAll();
    }

    public List<Dock> getFullDocks() {

	return _dbapi.getFull();
    }

    public List<Dock> getHalfDocks() {

	return _dbapi.getHalf();
    }

    public List<Dock> getEmptyDocks() {

	return _dbapi.getEmpty();
    }

    public Dock getDock(int id) {

	return _dbapi.getDock(id);
    }

    public long insertDock(Dock d) {

	return _dbapi.insertDock(d);
    }

    public long updateDock(int id, int free, int available) {

	return _dbapi.updateDock(id, free, available);
    }
    
    public List<Dock> getNotFullDocks() {
	
	return _dbapi.getNotFull();
    }
    
    public List<Dock> getNotEmptyDocks() {
    
    return _dbapi.getNotEmpty();
    }

}
